package greentycoon.batiment;

import greentycoon.ville.Dechet;
import greentycoon.ville.Impot;
import greentycoon.ville.Pollution;
import greentycoon.ville.Quartier;

import java.util.Random;

import org.omg.PortableInterceptor.INACTIVE;

public class Habitation extends Batiment {

	/*Attributs*/
	String classeSociale;
	public static final int sizeX =1;
	public static final int sizeY =1;
	private boolean inhabited;
	private Impot impot;
	private Dechet tauxDechetQuotidient = new Dechet();
	private Quartier quartier;
	
	/*Methodes*/
	public Habitation(int x, int y){
		posX = x;
		posY = y;
		classeSociale ="moyenne";
		tauxDechetQuotidient.ajouterUltime(2);
		PuissanceConsome = 7;
		inhabited = true;
		impot = new Impot(1);
		pollution.setPollutionAir(1);
	}
	
	public Habitation(int x, int y, String _classeSociale){
		posX = x;
		posY = y;
		classeSociale = _classeSociale;
	}

	public String getClasseSociale() {
		return classeSociale;
	}

	public void setClasseSociale(String classeSociale) {
		this.classeSociale = classeSociale;
		
		if(classeSociale.equals("pauvre")){
			tauxDechetQuotidient.ajouterUltime(1);
		}else if (classeSociale.equals("moyenne")){
			tauxDechetQuotidient.ajouterUltime(2);
		}else if (classeSociale.equals("riche")){
			tauxDechetQuotidient.ajouterUltime(3);
		}
	}
	
	public  int getSizeX() {
		
		return sizeX;
	}

	public  int getSizeY() {
		return sizeY;
	}

	public boolean isInhabited() {
		return inhabited;
	}

	public void setInhabited(boolean inhabited) {
		this.inhabited = inhabited;
		if(inhabited)
		{
			pollution.setPollutionAir(1);
		}else{
			pollution.setPollutionAir(0);
		}
	}
	
	public void rafraichirInformations(Pollution pol){

		Random r = new Random();
		int valeur =  r.nextInt(100);
		if((pol.getPollutionAir()>100 || pol.getPollutionSol()>100)
			&& (valeur < pol.getPollutionAir()-100 || valeur < pol.getPollutionSol()-100 )
			|| compteurInhabited>3)
		{
			setInhabited(false);
		}else{
			setInhabited(true);
		}
		
	}

	public Impot getImpot() {
		return impot;
	}

	public void setImpot(Impot impot) {
		this.impot = impot;
	}

	public Dechet getTauxDechetQuotidient() {
		if(inhabited == true)
		{
			return tauxDechetQuotidient;
		}else
		{
			return new Dechet();
		}
	}

	public void setTauxDechetQuotidient(Dechet tauxDechetQuotidient) {
		this.tauxDechetQuotidient = tauxDechetQuotidient;
	}

	public Quartier getQuartier() {
		return quartier;
	}

	public void setQuartier(Quartier quartier) {
		this.quartier = quartier;
	}

	
	
	
	
}
